package duotai;

public class Test {

    public static void testVoice(Animal c){
        c.voice();
        if(c instanceof Cat){
            ((Cat) c).catchMouse();
        }
    }
//    public static void testVoice(Dog c){
//        c.voice();
//    }
//    public static void testVoice(Pig c){
//        c.voice();
//    }
    public static void main(String[] args){
//        Cat c = new Cat();
//        testVoice(c);

        Animal a = new Cat();//父类对象指向了一个子类
        Cat a2 = (Cat) a;
        testVoice(a);
        //Animal.run();
    }
}
